home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 4216 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: inforamp.net!ts44-07
  2. From: rmorin@inforamp.net (Randy Charles Morin)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Newbie C programmer needs help Please!!!
  5. Date: Fri, 02 Feb 96 18:29:49 GMT
  6. Organization: MiddleWorld SoftWare
  7. Message-ID: <4etksv$7s1@sam.inforamp.net>
  8. References: <4eca9l$vfn@grouper.Exis.Net>
  9. NNTP-Posting-Host: ts44-07.tor.inforamp.net
  10. X-Newsreader: News Xpress Version 1.0 Beta #4
  11.  
  12. In article <4eca9l$vfn@grouper.Exis.Net>, herborn@exis.net wrote:
  13. >I'm taking a C course and have an assignment to write a C program to
  14. >compute all the combo's of coins that can make up a dollar.  I've been
  15. >working on the solution to this for a couple of days and can't get it.
  16. >
  17. >
  18. >Anyone willing to jump start my brain for me.  I'm not looking for
  19. >someone else to do my work, just some pointers on how to tackle the
  20. >task.   Code is supposed to be simple,  the farthest we've gone in
  21. >class is loops & simple functions.
  22. >
  23. >If you're willing to help, please respond via e-mail.
  24. >
  25. >TIA
  26. >
  27. >Steve
  28. >
  29.  
  30. I'm from Canada so we might make a culture differences.
  31. Four quarters make a dollar, ten dimes, twenty nickles, 100 pennies.
  32. Thus we have,
  33.  
  34. int q,d,n,p;
  35. for (q=0;q<5;q++)
  36. for (d=0;d<11;d++)
  37. for (n=0;n<21;n++)
  38. for (p=0;p<101;p++)
  39. if (q*25+d*10+n*5+p==100)
  40. {
  41.     /* print result */
  42.     cprintf("%d quarters, %d dimes, %d nickles, %d pennies", q, d, n, p);
  43. }
  44.  
  45. Agrivar
  46.